feat(apply): persist planned deployment state (issue #15)#49
Merged
Conversation
Add Applier.ApplyPlan and executor to upsert/delete applied_resources and upsert applied_projects using env and project spec_hash as version. Extend plan.Operation with SpecHash and NormalizedSpecJSON; add ProjectDeploymentMeta. DeploymentStore gains DeleteAppliedResource; sqlite refactors deployment SQL into deployment_ops and implements TransactionalDeployment via RunDeploymentTx. Tests cover apply then list/get and delete removing rows (issue #15). Made-with: Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements local apply semantics from the design doc (§12.2 D, §16): persist desired deployment rows to SQLite, not remote deploy.
What changed
internal/applyapplier.go:Applier.ApplyPlan(ctx, env, graph, plan, at)runs all plan operations then updatesapplied_projects. KeepsRecordAppliedResourcefor direct upserts.executor.go: For each operation—create/update →UpsertAppliedResourcewithspec_hashandnormalized_spec_json; delete →DeleteAppliedResource; finallyUpsertAppliedProjectwith project name and version.internal/planOperationnow carriesSpecHashandNormalizedSpecJSONfor create/update so apply does not re-derive material.project_meta.go:ProjectDeploymentMeta(graph)returns project name and project resourcespec_hashforapplied_projects.version.internal/stateDeploymentStore: newDeleteAppliedResource.TransactionalDeployment:RunDeploymentTx(fn)for atomic apply.internal/state/sqlitedeployment_ops.go: shared SQL helpers using aquerier(*sql.DB/*sql.Tx).deployment_tx.go:deploymentStoreTx+(*Store).RunDeploymentTx.store.go: thin wrappers; idempotent delete (no error if row missing).Tests
TestApplyPlan_thenListShowsResources: plan → apply → list/get shows project row andapplied_projectsrow with non-empty version.TestApplyPlan_deleteRemovesRow: apply full graph, then plan with agent removed → apply → agentGetAppliedResourcereturnssql.ErrNoRows.Verification
make fmt(go fmt ./...)make test(go test ./... -race)make vetCloses #15
Made with Cursor